package com.ruoyi.project.mahjong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mahjong.domain.ShopLog;
import com.ruoyi.project.mahjong.service.IShopLogService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 店铺日志Controller
 * 
 * @author ruoyi
 * @date 2023-12-01
 */
@RestController
@RequestMapping("/mahjong/shoplog")
public class ShopLogController extends BaseController
{
    @Autowired
    private IShopLogService shopLogService;

    /**
     * 查询店铺日志列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shoplog:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopLog shopLog)
    {
        startPage();
        List<ShopLog> list = shopLogService.selectShopLogList(shopLog);
        return getDataTable(list);
    }

    /**
     * 导出店铺日志列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shoplog:export')")
    @Log(title = "店铺日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShopLog shopLog)
    {
        List<ShopLog> list = shopLogService.selectShopLogList(shopLog);
        ExcelUtil<ShopLog> util = new ExcelUtil<ShopLog>(ShopLog.class);
        return util.exportExcel(list, "shoplog");
    }

    /**
     * 获取店铺日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shoplog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shopLogService.selectShopLogById(id));
    }

    /**
     * 新增店铺日志
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shoplog:add')")
    @Log(title = "店铺日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopLog shopLog)
    {
        return toAjax(shopLogService.insertShopLog(shopLog));
    }

    /**
     * 修改店铺日志
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shoplog:edit')")
    @Log(title = "店铺日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopLog shopLog)
    {
        return toAjax(shopLogService.updateShopLog(shopLog));
    }

    /**
     * 删除店铺日志
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shoplog:remove')")
    @Log(title = "店铺日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopLogService.deleteShopLogByIds(ids));
    }
}
